import requests


class TpshopLoginAPI:
    # 获取验证码方法
    @classmethod
    def get_verify_code(cls, session):
        session.get(url="http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=verify")

    # 登录方法
    @classmethod
    def login(cls, session, data):
        url = "http://tpshop-test.itheima.net/index.php?m=Home&c=User&a=do_login"
        header = {"Content-Type": "application/x-www-form-urlencoded"}
        resp = session.post(url=url, data=data, headers=header)
        return resp


class RegisterApi:
    @classmethod
    def get_verify_code01(cls, session):
        session.get('http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.4459692913599851')

    @classmethod
    def register(cls, session, data):
        url = "http://hmshop-test.itheima.net/Home/User/reg.html"
        header = {"Content-Type": "application/x-www-form-urlencoded"}
        resp = session.post(url=url, headers=header, data=data)
        return resp


class IhrmLoginApi:
    # 获取登录接口
    @classmethod
    def login(cls, data):
        url = "http://ihrm-test.itheima.net/api/sys/login"
        header = {"Content-Type": "application/json"}
        resp = requests.post(url=url, headers=header, json=data)
        return resp


class IhrmAddApi:
    # 获取添加员工接口
    @classmethod
    def add(cls, data, token):
        url = "http://ihrm-test.itheima.net/api/sys/user"
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.post(url=url, headers=header, json=data)
        return resp


class IhrmSearchApi:
    # 获取查找员工接口
    @classmethod
    def Search(cls, emp_id, token):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id
        header = {"Authorization": token}
        resp = requests.get(url=url, headers=header)
        print(url)
        return resp


class IhrmUpdateApi:
    # 获取查找员工接口
    @classmethod
    def update(cls, emp_id, token, data):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id
        header = {"Content-Type": "application/json", "Authorization": token}
        resp = requests.put(url=url, headers=header, json=data)
        return resp


class IhrmDeleteApi:
    # 获取删除员工接口
    @classmethod
    def update(cls, emp_id, token):
        url = "http://ihrm-test.itheima.net/api/sys/user/" + emp_id
        header = {"Authorization": token}
        resp = requests.delete(url=url, headers=header)
        return resp
